<?php
//echo $extra;
	if ($extra == 'NSW')
	{
		$type_id = JOBTYPE_NSW;
		$city_id = false;
	}
	else if ($extra == 'VIC')
	{
		$type_id = JOBTYPE_VIC;
		$city_id = false;
	}
	else if ($extra == 'QLD')
	{
		$type_id = JOBTYPE_QLD;
		$city_id = false;
	}
		else if ($extra == 'SA')
	{
		$type_id = JOBTYPE_SA;
		$city_id = false;
	}
		else if ($extra == 'NT')
	{
		$type_id = JOBTYPE_NT;
		$city_id = false;
	}
		else if ($extra == 'WA')
	{
		$type_id = JOBTYPE_WA;
		$city_id = false;
	}
		else if ($extra == 'TAS')
	{
		$type_id = JOBTYPE_TAS;
		$city_id = false;
	}
		else if ($extra == 'ACT')
	{
		$type_id = JOBTYPE_ACT;
		$city_id = false;
	}
	else
	{
		$type_id = false;
		$city_id = false;
	}
	
	//echo $type_id;
//echo $id;
	if($type_id && $id != 'all')
	{
		if ($job->IsValidCategory($id))
		{
			$jobCount =  $job->CountJobs($id, $type_id);
			$smarty->assign('jobs_count', $jobCount);
		}
		else
		{
			redirect_to(BASE_URL . 'page-unavailable/');
			exit;
		}
	}
	
	if (!$type_id && $id != 'all')
	{
		if ($job->IsValidCategory($id))
		{
			
			$jobCount =  $job->CountJobs($id);
			$smarty->assign('jobs_count', $jobCount);
		}
		else
		{
			redirect_to(BASE_URL . 'page-unavailable/');
			exit;
		}
	}
	else if($id == 'all')
	{
		$jobCount =  $job->CountJobs();
		$smarty->assign('jobs_count', $jobCount);
	}
	
	$paginatorLink = BASE_URL . "realestates/$id";
	
	if (isset($extra))
		$paginatorLink .= "/$extra";
		
	$paginator = new Paginator($jobCount, JOBS_PER_PAGE, @$_REQUEST['p']);
	$paginator->setLink($paginatorLink);
	$paginator->paginate();
	
	$firstLimit = $paginator->getFirstLimit();
	$lastLimit = $paginator->getLastLimit();
	
	$the_jobs = array();
	$the_jobs = $job->GetJobsPaginate(0, $id, $firstLimit, JOBS_PER_PAGE, 0, 0, false, $city_id, $type_id,0);
	$smarty->assign("pages",$paginator->pages_link);
	
	$smarty->assign('jobs', $the_jobs);
	$smarty->assign('current_category', $id);


	$smarty->assign('id',$id);
	
	///////////////////
		$sql = "SELECT property_city_list.id as sid, property_city_list.gamearea as gamearea,property_state_list.gamename gname
						FROM property_city_list LEFT JOIN property_state_list
						ON (property_state_list.id = property_city_list.gameid)
						WHERE property_city_list.isgamearea=1";
	$comps = $db->QueryArray($sql);
	
	$state_array=array();						
	$city_array=array();						
	foreach ($comps as $companya)
	{
		$sid = $companya['sid'];
		$city_array[$sid] = $companya['gamearea'];	 
		$state_array[$sid] = $companya['gname'];	
	}
	
	//print_r($city_array);
	$smarty->assign('city_array', $city_array);
	$smarty->assign('state_array', $state_array);
	
	
			$smarty->assign('property_array',$property_array);	
	$smarty->assign('property_array2',$property_array2);
	$smarty->assign('seo_title', get_seo_title($id));
	$smarty->assign('seo_desc', get_seo_desc($id));
	$smarty->assign('seo_keys', get_seo_keys($id));

	$template = 'category.tpl';
?>